#!/bin/sh

writelines() {
   for i in *.py 
     do
     if [ ${i} != "__init__.py" ]
     then
       echo $2${i} >> $1
     fi
    done
}

cd $(dirname "$0")

echo
echo Updating POTFILES.in...

rm ../po/POTFILES.in
touch ../po/POTFILES.in
cd ..
writelines po/POTFILES.in ./

cd foobnix/application
writelines ../../po/POTFILES.in ./foobnix/application/

cd ../directory
writelines ../../po/POTFILES.in ./foobnix/directory/

cd ../lyric
writelines ../../po/POTFILES.in ./foobnix/lyric/

cd ../online
writelines ../../po/POTFILES.in ./foobnix/online/

cd ../playlist
writelines ../../po/POTFILES.in ./foobnix/playlist/

cd ../util
writelines ../../po/POTFILES.in ./foobnix/util/

cd ../glade
intltool-extract --type=gettext/glade foobnix.glade
echo ./foobnix/glade/foobnix.glade.h >> ../../po/POTFILES.in

cd ../../po

echo Update messages.po...
echo

intltool-update -p
mv untitled.pot messages.po

for i in *.po 
  do
  if [ "$i" = "messages.po" ]
    then
    continue
  fi
  echo Updating ${i}...
  intltool-update "${i%*.po}"
  echo
done

echo Cleaning up...
echo

rm untitled.pot
